package com.boarsoft.boar.soagov.svc.service;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;

import com.boarsoft.boar.soagov.entity.FaceInfo;
import com.boarsoft.boar.soagov.face.FaceBiz;
import com.boarsoft.boar.soagov.svc.FaceInfoService;

@Component("faceInfoService")
public class FaceInfoServiceImpl implements FaceInfoService {
	private static final Logger log = LoggerFactory.getLogger(FaceInfoService.class);
	@Resource
	private FaceBiz faceBiz;

	@Override
	public String save(FaceInfo faceInfo) {
		log.info("Recevied face info {}", faceInfo);
		try {
			return faceBiz.save(faceInfo);
		} catch (DataIntegrityViolationException e) {
			return faceBiz.selectFaceId(faceInfo);
		}
	}
}
